package canchaFulbito.servletacceso;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import canchaFulbito.excepcion.DAOExcepcion;
import canchaFulbito.negocio.SeguridadNegocio;

/**
 * Servlet implementation class RegistrarCanchaServlet
 */
public class RegistrarCanchaServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public RegistrarCanchaServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		RequestDispatcher rd;
		String msg = "";
		SeguridadNegocio neg = new SeguridadNegocio();
		
		HttpSession session = request.getSession(true);
		int valor = 0;
		/*
		try {

			
			if(request.getParameter("txtNombre")!=""&
					request.getParameter("txtCaract")!=""&
					request.getParameter("foto")!=""&
					request.getParameter("selLocal")!=""
					)
			{
						
						String NomCancha= request.getParameter("txtNombre");
						String Caracteristicas= request.getParameter("txtCaract");
						String Foto=request.getParameter("foto");
						int idLocal= Integer.parseInt(request.getParameter("selLocal"));
						
						 //valor = neg.insertarCancha(NomCancha, Caracteristicas, Foto, idLocal);
						 System.out.print("entro aqui-->" + valor);
						 if (valor==1)
						 {
								msg = "Registrado Duplicado";
								request.setAttribute("MENSAJE", msg);
								rd = request.getRequestDispatcher("RegistrarCancha.jsp");
								rd.forward(request, response);
						 }else{
								msg = "Registrado Satisfactoriamente";
								request.setAttribute("MENSAJE", msg);
								rd = request.getRequestDispatcher("RegistrarCancha.jsp");
								rd.forward(request, response); 
						 }
							
						
					}
					else{
						msg = "No puede ingresar Campos en blanco";
						request.setAttribute("MENSAJE", msg);
						rd = request.getRequestDispatcher("RegistrarCancha.jsp");
						rd.forward(request, response);
					}
		} catch (DAOExcepcion e)  {
			
			if(valor==1){
				msg = "Registrado Ya existe, vuelva a Ingresar los datos";
				request.setAttribute("MENSAJE", msg);
				rd = request.getRequestDispatcher("RegistroLocal.jsp");
				rd.forward(request, response);
			}
			msg="Debe ingresar los campos necesarios";
			request.setAttribute("MENSAJE", msg);
			rd = request.getRequestDispatcher("RegistroLocal.jsp");
			rd.forward(request, response);
						}
			}
	*/
	}
}

